<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * 后台管理左侧菜单
 * @author 		dd
 * @qq                                  451963230
 * @email		451963230@qq.com
 */
class Products extends Admin_Controller
{

    function __construct()
    {
        parent::__construct();
        $this->load->model('JayphaDB');
        if (is_null($this->adminCurrentTemplate) or empty($this->adminCurrentTemplate))
        {
            $this->adminCurrentTemplate = 'default';
        }
        $this->dbTablePrefix = $this->config->item('db_table_prefix');
    }

    function index()
    {
        if (!$this->noLoginErr())
            return false;
        $tvName = 'admin_menu';
        $parentId = $this->uri->segment(4);
        if (strlen($parentId) == 0)
        {
            $parentId = $this->JayphaDB->getDBValue('id', $this->dbTablePrefix . $tvName, array('disabled' => false, 'parentId' => 0), 'oIndex,id');
        }
        $data['adminMenuTitle'] = $this->JayphaDB->getDBValue('title', $this->dbTablePrefix . $tvName, array('id' => $parentId), '');
        $where = array('disabled' => false, 'parentId' => $parentId);
        $order = 'oIndex,id';
        $channelSide = array();
        if ($parentId == 3)
        {
            $channelList = $this->JayphaDB->getDB(0, 0, 'id,title,adminMainCon,adminEditCon,identifier', $this->dbTablePrefix . 'channel', array('disabled' => 0), 'id', true);
            for ($i = 0; $i < count($channelList); $i++)
            {
                $channelSide[$i]->title = $channelList[$i]->title . '管理';
                $channelSide[$i]->url = $channelList[$i]->adminMainCon;
                $channelSide[$i]->identifier = $channelList[$i]->identifier;
            }
        }
        $data['adminMenuChild'] = $this->JayphaDB->getDB(0, 0, '', $this->dbTablePrefix . $tvName, $where, $order, true);
        if (count($channelSide) > 0 && count($data['adminMenuChild']))
        {
            foreach ($channelSide as $item)
            {
                $data['adminMenuChild'][count($data['adminMenuChild'])] = $item;
            }
        } else if (count($channelSide) > 0 && count($data['adminMenuChild']) == 0)
        {
            $data['adminMenuChild'] = $channelSide;
        } else
        {
            unset($channelSide);
        }
        $data['adminPermission'] = $this->JayphaDB->getAdminPermission($this->session->userdata('adminUserId'));
        $this->load->view("admin/$this->adminCurrentTemplate/product_index", $data);
    }

    public function productAdd()
    {
        echo 1;
    }

    public function productEdit()
    {
        echo 2;
    }

}

/* End of file side.php */
/* Location: ./application/controllers/admin/products.php */